﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace NMigrate.Versioning
{
	public class FileVersionHandler : VersionHandler
	{
		private readonly string _Path;
		public string Path
		{
			get
			{
				return _Path;
			}
		}

		public FileVersionHandler(string path)
		{
			_Path = path;
		}


		#region VersionHandler Members

		public int GetVersion()
		{
			if(!File.Exists(Path))
				return 0;
			return int.Parse(File.ReadAllText(Path));
		}

		public void SetVersion(int version)
		{
			File.WriteAllText(Path, version.ToString());
		}

		#endregion
	}
}
